package com.bachongLightNovel.works.fallback;

import com.bachongLightNovel.model.dto.audit.AuditNovelDto;
import com.bachongLightNovel.model.vo.audit.AuditNovelVo;
import com.bachongLightNovel.works.IWorksNovelClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.openfeign.FallbackFactory;

import java.util.Collections;
import java.util.List;

/**
 * @author vermouth
 */
@Slf4j
public class WorksNovelClientFallbackFactory implements FallbackFactory<IWorksNovelClient> {

    /**
     * @param cause
     * @return
     */
    @Override
    public IWorksNovelClient create(Throwable cause) {
        return new IWorksNovelClient() {
            @Override
            public List<AuditNovelVo> getAuditList() {
                log.error("调用feign出现错误",cause);
                return Collections.emptyList();
            }

            @Override
            public boolean setAuditStatus(AuditNovelDto dto) {
                log.error("调用feign出现错误",cause);
                return false;
            }

            /**
             * 根据小说名获取小说id
             * @param novelName :
             * @return Long
             */
            @Override
            public List<Long> getNovelIdByNovelName(String novelName) {
                return null;
            }

            /**
             * 根据小说id获取小说名
             * @param novelId :
             * @return String
             */
            @Override
            public String getNovelNameById(Long novelId) {
                return null;
            }
        };
    }
}
